package com.service.atf.base.model;

import com.service.atf.base.core.ByteConvertion;
import com.luotao.devp.base.utils.ByteUtil;

/**
 * User: luotao
 * Date: 12-2-23
 * Time: 11:34:00
 */
public class BaseFlow extends BaseHeader implements ByteConvertion {
    protected static final int LEN_FLOW = 113;

    public static final int LEN_ALL = LEN_HEAD + LEN_FLOW;

    // ���׷���ʽ	Byte		ǰ��
    private byte sendType;
    //�����˻����׽��	����long	��λ����	ǰ��
    private long chargeTradeMoney;
    //�����˻�����ǰ���	����long		ATF
    private long chargeBeforeTrade;
    //�����˻����׺����	����long		ATF
    private long chargeAfterTrade;

    //���񽱽��˻����׽��	����long	��λ����	ǰ��
    private long awardTradeMoney;
    //���񽱽��˻�����ǰ���	����long		ATF
    private long awardBeforeTrade;
    //���񽱽��˻����׺����	����long		ATF
    private long awardAfterTrade;

    //�����˻����׷���ʱ��	int	2000�굽���ڵĺ�������ȡ��2λ	MP
    private int createDate;
    //�����˻�����ȷ��ʱ��	int	2000�굽���ڵĺ�������ȡ��2λ	MP
    private int confirmDate;

    //ӳ�佻����ˮID	char(24)	����ǰһ�ʽ���	ǰ��
    private String mappedFlowId;
    //������ϢժҪ	Char(16)		ATF
    private String tradeMemo;

    public String getFlowId() {
        return flowId;
    }

    public void setFlowId(String flowId) {
        this.flowId = flowId;
    }


    public byte getSendType() {
        return sendType;
    }

    public void setSendType(byte sendType) {
        this.sendType = sendType;
    }

    public long getChargeTradeMoney() {
        return chargeTradeMoney;
    }

    public void setChargeTradeMoney(long chargeTradeMoney) {
        this.chargeTradeMoney = chargeTradeMoney;
    }

    public long getChargeBeforeTrade() {
        return chargeBeforeTrade;
    }

    public void setChargeBeforeTrade(long chargeBeforeTrade) {
        this.chargeBeforeTrade = chargeBeforeTrade;
    }

    public long getChargeAfterTrade() {
        return chargeAfterTrade;
    }

    public void setChargeAfterTrade(long chargeAfterTrade) {
        this.chargeAfterTrade = chargeAfterTrade;
    }

    public int getCreateDate() {
        return createDate;
    }

    public void setCreateDate(int createDate) {
        this.createDate = createDate;
    }

    public int getConfirmDate() {
        return confirmDate;
    }

    public void setConfirmDate(int confirmDate) {
        this.confirmDate = confirmDate;
    }


    public String getMappedFlowId() {
        return mappedFlowId;
    }

    public void setMappedFlowId(String mappedFlowId) {
        this.mappedFlowId = mappedFlowId;
    }

    public String getTradeMemo() {
        return tradeMemo;
    }

    public void setTradeMemo(String tradeMemo) {
        this.tradeMemo = tradeMemo;
    }

    public long getAwardTradeMoney() {
        return awardTradeMoney;
    }

    public void setAwardTradeMoney(long awardTradeMoney) {
        this.awardTradeMoney = awardTradeMoney;
    }

    public long getAwardBeforeTrade() {
        return awardBeforeTrade;
    }

    public void setAwardBeforeTrade(long awardBeforeTrade) {
        this.awardBeforeTrade = awardBeforeTrade;
    }

    public long getAwardAfterTrade() {
        return awardAfterTrade;
    }

    public void setAwardAfterTrade(long awardAfterTrade) {
        this.awardAfterTrade = awardAfterTrade;
    }

    public void byte2ObjectFlow(byte[] src) {
        byte2ObjectHeader(src);
        setSendType((byte) ByteUtil.read(src, LEN_HEAD));
        setChargeTradeMoney(ByteUtil.readLong(src, 1 + LEN_HEAD));
        setChargeBeforeTrade(ByteUtil.readLong(src, 9 + LEN_HEAD));
        setChargeAfterTrade(ByteUtil.readLong(src, 17 + LEN_HEAD));
        setAwardTradeMoney(ByteUtil.readLong(src, 25 + LEN_HEAD));
        setAwardBeforeTrade(ByteUtil.readLong(src, 33 + LEN_HEAD));
        setAwardAfterTrade(ByteUtil.readLong(src, 41 + LEN_HEAD));
        setCreateDate(ByteUtil.readInt(src, 49 + LEN_HEAD));
        setConfirmDate(ByteUtil.readInt(src, 53 + LEN_HEAD));
        setMappedFlowId(ByteUtil.readString(src, 57 + LEN_HEAD, 24));
        setTradeMemo(ByteUtil.readString(src, 81 + LEN_HEAD, 32));
    }

    public int getLenAll() {
        return LEN_FLOW + LEN_HEAD;
    }

    public byte[] object2ByteFlow() {
        byte[] src = new byte[getLenAll()];
        byte[] head = object2ByteHeader();
        System.arraycopy(head, 0, src, 0, head.length);
        ByteUtil.write(src, LEN_HEAD, getSendType());
        ByteUtil.writeLong(src, 1 + LEN_HEAD, getChargeTradeMoney());
        ByteUtil.writeLong(src, 9 + LEN_HEAD, getChargeBeforeTrade());
        ByteUtil.writeLong(src, 17 + LEN_HEAD, getChargeAfterTrade());
        ByteUtil.writeLong(src, 25 + LEN_HEAD, getAwardTradeMoney());
        ByteUtil.writeLong(src, 33 + LEN_HEAD, getAwardBeforeTrade());
        ByteUtil.writeLong(src, 41 + LEN_HEAD, getAwardAfterTrade());
        ByteUtil.writeInt(src, 49 + LEN_HEAD, getCreateDate());
        ByteUtil.writeInt(src, 53 + LEN_HEAD, getConfirmDate());
        ByteUtil.writeString(src, 57 + LEN_HEAD, getMappedFlowId(), 24);
        ByteUtil.writeString(src, 81 + LEN_HEAD, getTradeMemo(), 32);
        return src;
    }

    @Override
    public ByteConvertion byte2Object(byte[] src) {
        return null;
    }

    @Override
    public byte[] object2Byte() {
        return new byte[0];
    }
}
